//
//  LWShopCarTBottomiew.m
//  LWShopItem
//
//  Created by apple on 17/4/14.
//  Copyright © 2017年 LWShop.com. All rights reserved.
//

#import "LWShopCarTBottomiew.h"
#import "LWAccountViewController.h"
#import "LWDetailModel.h"

@interface LWShopCarTBottomiew()
@property (weak, nonatomic) IBOutlet UIButton *controlBtn;
@property (weak, nonatomic) IBOutlet UIButton *selBtn;

@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@end

@implementation LWShopCarTBottomiew

- (IBAction)payClick:(id)sender {
    
    NSLog(@"点击了去结算按钮");
    
    if ([_delegate respondsToSelector:@selector(jumpToPay)]) {
        [_delegate jumpToPay];
    }
    
    
    
    
}

- (IBAction)selectAllClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.tag == 0) {
        if (sender.selected) {
            self.isSelectedAll = YES;
        } else {
            self.isSelectedAll = NO;
        }
    }
    if (sender.tag == 1) {
        if (sender.selected) {
            self.isSelectedAll = YES;
        } else {
            self.isSelectedAll = NO;
        }
    }
    if ([_delegate respondsToSelector:@selector(selectAllOrCancleAll:)]) {
        [_delegate selectAllOrCancleAll:_isSelectedAll];
    }
    
}
+ (instancetype)shopCarBottomView {
    return [[NSBundle mainBundle] loadNibNamed:@"LWShopCarBottomView" owner:nil options:nil].lastObject;

}
- (void)awakeFromNib {
    [super awakeFromNib];
    self.layer.borderWidth = 1;
    self.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.controlBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.controlBtn.layer.borderWidth = 1;
}

- (void)setIsSelectedAll:(BOOL)isSelectedAll {
    _isSelectedAll = isSelectedAll;
    if (_isSelectedAll) {
        [_controlBtn setImage:[UIImage imageNamed:@"xuanze"] forState:UIControlStateNormal];
        _controlBtn.selected = YES;
        _selBtn.selected = YES;
    } else {
        [_controlBtn setImage:nil forState:UIControlStateNormal];
        _controlBtn.selected = NO;
        _selBtn.selected = NO;
    }
}

- (void)setAllPrice:(double)allPrice {
    _allPrice = allPrice;
    _priceLabel.text = [NSString stringWithFormat:@"¥%.2lf元",_allPrice];
}
@end
